//主控模块
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        UserManager userManager = new UserManager();

        System.out.println("=== 欢迎使用图书馆管理系统 ===");
        while (true) {
            System.out.println("1. 登录");
            System.out.println("2. 注册");
            System.out.println("3. 退出");
            System.out.print("请选择操作：");
            int choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    if (userManager.login()) {
                        showMainMenu();
                    }
                    break;
                case 2:
                    userManager.register();
                    break;
                case 3:
                    System.out.println("感谢使用，再见！");
                    return;
                default:
                    System.out.println("无效选择，请重试。");
            }
        }
    }

    private static void showMainMenu() {
        Scanner scanner = new Scanner(System.in);
        BookManager bookManager = new BookManager();
        BorrowManager borrowManager = new BorrowManager();
        ReaderManager readerManager = new ReaderManager();

        while (true) {
            System.out.println("\n=== 主菜单 ===");
            System.out.println("1. 图书管理");
            System.out.println("2. 借阅管理");
            System.out.println("3. 读者管理");
            System.out.println("4. 退出登录");
            System.out.print("请选择操作：");
            int choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    bookManager.menu();
                    break;
                case 2:
                    borrowManager.menu();
                    break;
                case 3:
                    readerManager.menu();
                    break;
                case 4:
                    System.out.println("退出登录，返回主界面。");
                    return;
                default:
                    System.out.println("无效选择，请重试。");
            }
        }
    }
}